package cn.south.campus.admin.sys.model.vo;

import cn.south.campus.admin.sys.model.entity.SysRole;
import cn.south.campus.common.model.vo.BaseVO;
import cn.south.campus.common.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Set;

/**
 * @author chow
 * @since 2024/10/31
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class SysRoleVo extends BaseVO {

    /**
     * 角色名称
     */
    private String roleName;

    /**
     * 角色描述
     */
    private String roleDesc;

    /**
     * 菜单集合
     */
    private Set<Long> menuIds;

    public static SysRoleVo convert(SysRole sysRole) {
        SysRoleVo sysRoleVo = new SysRoleVo();
        sysRoleVo.setId(sysRole.getId());
        sysRoleVo.setRoleName(sysRole.getRoleName());
        sysRoleVo.setRoleDesc(sysRole.getRoleDesc());
        sysRoleVo.setCreateTime(DateUtil.format(sysRole.getCreateTime()));
        sysRoleVo.setUpdateTime(DateUtil.format(sysRole.getUpdateTime()));
        return sysRoleVo;
    }
    public static SysRole convert(SysRoleVo vo) {
        SysRole entity = new SysRole();
        entity.setId(vo.getId());
        entity.setRoleName(vo.getRoleName());
        entity.setRoleDesc(vo.getRoleDesc());
        entity.setCreateTime(DateUtil.parseString(vo.getCreateTime()));
        entity.setUpdateTime(DateUtil.parseString(vo.getUpdateTime()));
        return entity;
    }
}
